import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../layout/index'

Vue.use(Router)

export const constantRouterMap = [
  // cockpit Begin
  {
    path: '/cockpit',
    name: 'cockpit',
    component: () => import(/* webpackChunkName: "cockpit" */ '@/views/cockpit/pageLayout.vue'),
    children: [
      {
        path: '/cockpit/home',
        name: 'cockpitHome',
        component: () => import(/* webpackChunkName: "cockpit" */ '@/views/cockpit/home/index.vue'),
      },
    ],
    hidden: true
  },
  {
    path: '/cockpitDemo',
    component: () => import(/* webpackChunkName: "cockpit" */'@/views/homePage/components/cockpitDemo.vue'),
    hidden: true
  },
  // cockpit　end
  {
    path: '/login',
    meta: { title: '登录', noCache: true },
    component: (resolve) => require(['@/views/login'], resolve),
    hidden: true
  },
  {
    path: '/register/step1',
    meta: { title: '注册', noCache: true },
    component: (resolve) => require(['@/views/register/step1'], resolve),
    hidden: true
  },
  {
    path: '/register/step2',
    meta: { title: '更改密码', noCache: true },
    component: (resolve) => require(['@/views/register/step2'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/features/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/features/401'], resolve),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: (resolve) => require(['@/views/features/redirect'], resolve)
      }
    ]
  },
  {
    path: '/projectManagement/sectionManage',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/projectManagement/sectionManage',
        component: (resolve) => require(['@/views/projectManagement/info/sectionManage/sectionManage'], resolve),
        name: '标段',
        meta: { title: '标段' }
      }
    ]
  },
  // {
  //   path: '/',
  //   component: Layout,
  //   hidden: false,
  //   redirect: '/dashboard',
  //   children: [
  //     {
  //       path: '/dashboard',
  //       component: (resolve) => require(['@/views/home'], resolve),
  //       name: 'Dashboard',
  //       meta: {title: '首页', icon: 'dashboard', affix: true, noCache: true}
  //     }
  //   ]
  // },
  {
    path: '/',
    component: Layout,
    hidden: true,
    redirect: '/homePage',
    children: [
      {
        path: '/homePage',
        component: (resolve) => require(['@/views/homePage/index2'], resolve),
        name: '1000017',
        meta: { title: '工作台', icon: 'dashboard', affix: true, noCache: true }
      }
    ]
  },
  {
    name: 'view',
    path: '/view',
    hidden: true,
    component: (resolve) => require(['@/views/form/design/index'], resolve),
    meta: {
      title: '表单编辑',
      icon: 'skill',
      noCache: true
    }
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'center',
        component: (resolve) => require(['@/views/system/user/center'], resolve),
        name: '个人中心',
        meta: { title: '个人中心' }
      }
    ]
  }
]

export default new Router({
  // mode: 'hash',
  // mode: 'history',  // history模式不支持ie， 刷新会404，需要nginx配置try_files $uri $uri/ /index.html;
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
